package jdk8的特性.Stream.去重筛选;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 获取奇数数字
 *
 * @author idea
 * @data 2018/9/8
 */
public class GetOddNumber {

    public static void main(String[] args) {
        List<Integer> integerList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5);
        //常规的过滤操作
        List<Integer> oddList = integerList.parallelStream()
                .filter((i) -> {
                    return i % 2 == 1;
                })
                .collect(Collectors.toList());
        oddList.forEach((item) -> {
            System.out.println(item);
        });

        System.out.println("-----------------");
        //常规的过滤操作
        List<Integer> distinctOddList = integerList.parallelStream()
                .filter((i) -> i % 2 == 1)
                .distinct()
                .collect(Collectors.toList());
        distinctOddList.forEach((item) -> {
            System.out.println(item);
        });
    }
}
